package com.test.service.impl;

import com.test.mapper.FoodMapper;
import com.test.pojo.Food;
import com.test.service.FoodService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author suxuexia
 * @create 2019-09-28 20:57
 */
@Service
public class FoodServiceImpl implements FoodService{
    @Resource
    FoodMapper foodMapper;

    @Override
    public List<Food> getAllFoodList() {
        return foodMapper.getAllFoodList();
    }

    @Override
    public int updateFood(Food food) {
        return foodMapper.updateFood(food);
    }

    @Override
    public int deleteFood(int foodId){
        int num = 0;
        try {
            num = foodMapper.deleteFood(foodId);
        }catch (Exception e){
            // 数据库异常
            num = -1;
        }
        return num;
    }
    @Override
    public int addFood(Food food) {
        return foodMapper.addFood(food);
    }
   @Override
    public List<Food> serachFood(String foodName) {
        return foodMapper.serachFood(foodName);
    }

    @Override
    public Food getFoodByID(int foodId) {
        return foodMapper.getFoodByID(foodId);
    }
}
